home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / Snippets / Nets & Comm / TCP Server / events.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-18  |  1.4 KB  |  60 lines  |  [TEXT/KAHL]

  1. /*
  2.     TCP Client/Server Queuing Example
  3.     Steve Falkenburg, MacDTS, Apple Computer
  4.     3/11/92
  5.     
  6.     this client/server sample uses MacTCP to implement a simple "greeting" server.  the server
  7.     opens up several listeners on kGreetingPort (1235).  when a client connects, the data entered
  8.     in the greeting dialog is sent to the remote connection, and the connection is closed.
  9.     
  10.     connection management is done through the use of Operating System queues to simplify tracking
  11.     and usage.
  12. */
  13.  
  14.  
  15. #include "const.h"
  16. #include "globals.h"
  17. #include "utils.h"
  18. #include "interface.h"
  19. #include "network.h"
  20. #include "queues.h"
  21. #include "events.h"
  22.  
  23. /*    event handling routine for dispatching non-null events.
  24.     we don't have much of a human interface, so we only handle
  25.     mousedowns.
  26. */
  27.  
  28. void HandleEvent(EventRecord *ev)
  29. {
  30.     if (HandleDialogEvents(ev))
  31.         return;
  32.     
  33.     switch (ev->what) {
  34.         case mouseDown:
  35.             HandleMouseDown(ev->where);
  36.             break;
  37.     }
  38. }
  39.  
  40.  
  41. /*    event handling routine for null-events.  this is where we check the queues
  42.     to see if we have anything in the "completed" queue.  if so, we call
  43.     ProcessConnection with the queue element parameter block which we receive,
  44.     and update our queue counter display.
  45. */
  46.  
  47. void HandleIdleTime(EventRecord *ev)
  48. {
  49.     MyQElemPtr pBlock;
  50.     
  51.     HandleDialogEvents(ev);
  52.     UpdateNumberList();
  53.     
  54.     while (pBlock = GetCompletedPBlock()) {
  55.         ProcessConnection(pBlock);
  56.     }
  57.  
  58.     UpdateNumberList();
  59. }
  60.